home *** CD-ROM | disk | FTP | other *** search
/ Directorty Opus 5 - Magellan 2 / Opus 5 - Magellan 2.iso / Extras / CDDAOpus / CDDAHandler.rexx next >
OS/2 REXX Batch file  |  1995-03-22  |  3KB  |  145 lines

  1. /*rx
  2.  * CDDAHandler - a Custom Handler for ListCDDA.rexx. Processes messages from
  3.  *              DOpus when the user double click's on a CustEntry.
  4.  *
  5.  * Based on LhaHandler by Geoff Seeley
  6.  *
  7.  * $VER: CDDAHandler 40.1 (25/12/94) by Laurie Lee
  8.  *
  9.  * Usage: Run >nil: <nil: RX CDDAHandler.rexx
  10.  *        (from S:User-Startup)
  11.  */
  12.  
  13. /*--------------------------------------------------------------------------*/
  14. /* misc. variables */
  15.  
  16. DOpusPort   = 'DOPUS.1'
  17. CDDAListPort = 'CDDALIST.1'
  18.  
  19. /* need rexxsupport.library for message functions */
  20.  
  21. if ~show(l,"rexxsupport.library") then        
  22.     call addlib("rexxsupport.library",0,-30,0)
  23.  
  24. /* check if we are already running */
  25.  
  26. if showlist('Ports', CDDAListPort) then do
  27.    call ExitIt
  28.  
  29. end
  30.  
  31. options results
  32.  
  33. /* open our message port */
  34.  
  35. OurPort = openport(CDDAListPort)
  36.  
  37. HandlerStatus = 'OPEN'
  38.  
  39. do until HandlerStatus = 'CLOSE'
  40.    call waitpkt(CDDAListPort)
  41.    Packet = getpkt(CDDAListPort)
  42.    if Packet ~= null() then do
  43.       Cmd = getarg(Packet, 0)
  44.       if Cmd = '1' | Cmd = '2' then do
  45.          Arg1 = getarg(Packet, 1) /* entry number */
  46.          Arg2 = getarg(Packet, 2) /* entry text   */
  47.          Arg3 = getarg(Packet, 3) /* userdata     */
  48.          call reply(Packet, 0)
  49.          address value DOpusPort
  50.          Busy on
  51.          if Cmd = '1' then
  52.             call HandleDoubleClick
  53.          Busy off
  54.       end
  55.       else
  56.          call reply(Packet, 0)
  57.       if Cmd = 'CLOSE' then
  58.          HandlerStatus = 'CLOSE'
  59.    end
  60. end
  61.  
  62. /* close up shop */
  63.  
  64. call closeport(OurPort)
  65.  
  66. exit
  67.  
  68. /*--------------------------------------------------------------------------*/
  69.  
  70. HandleDoubleClick: /* double click, view file */
  71.  
  72.    /* re-select this entry (double click unselects) */
  73.  
  74.   TrackNumber = ''
  75.   TrackNumber = substr(ARG2,1,3);
  76.  
  77.  
  78.   address YACDP 
  79.  
  80.   res=0;
  81.  
  82.   select
  83.     when ~compare(ARG2,"Previous") then do
  84.       lastsong
  85.       if RC > 0 then do
  86.         res=RC
  87.       end
  88.     end
  89.     when ~compare(ARG2,"Eject") then do
  90.       eject
  91.       if RC > 0 then do
  92.         res=RC
  93.       end
  94.     end
  95.     when ~compare(ARG2,"Stop") then do 
  96.       stop
  97.       if RC > 0 then do
  98.         res=RC
  99.       end
  100.     end
  101.     when ~compare(ARG2,"Pause") then do 
  102.       pause
  103.       if RC > 0 then do
  104.       res=RC
  105.       end
  106.     end
  107.     when ~compare(ARG2,"Next") then do
  108.       nextsong
  109.       if RC > 0 then do
  110.         res=RC
  111.       end
  112.     end
  113.     otherwise do
  114.       playtrack TrackNumber
  115.       if RC > 0 then do
  116.         res=RC
  117.       end
  118.     end
  119.   end
  120.  
  121.   address DOPUS.1 
  122.  
  123.   select
  124.     when res=10 then do
  125.       Notify "YACDP reports an\fatal error"
  126.     end
  127.     when res=15 then do
  128.       Notify "YACDP reports a SCSI error\Probably disk removed"
  129.     end
  130.     when res=20 then do
  131.       Notify "YACDP reports a terminal error\and has quit"
  132.     end
  133.     otherwise do
  134.       nop
  135.     end
  136.   end
  137.  
  138. return
  139.  
  140. ExitIt:
  141.  
  142.    exit
  143.  
  144. return
  145.